using System.Collections.Generic;
using System.Web.Mvc;
using etcetera.Mvc.UI.Html;
using Samples.Models;

namespace Samples.Controllers
{
    public class HtmlController : Controller
    {
        //
        // GET: /Html/
        //
        public ActionResult Index()
        {
            var gameConsoles = GetGameConsoles();

            GameConsoleViewModel gcvm = new GameConsoleViewModel();
            gcvm.GameConsoles = new OptionGroupSelectList<GameConsole>(gameConsoles, x => x.Id, x => x.Name, x => x.Manufacturer.Name);

            ViewData.Model = gcvm;

            return View();
        }

        private IEnumerable<GameConsole> GetGameConsoles()
        {
            IList<GameConsole> gcList = new List<GameConsole>();

            GameConsoleManufacturer m1 =  new GameConsoleManufacturer { Id = 1, Name = "Microsoft" };
            GameConsoleManufacturer m2 = new GameConsoleManufacturer { Id = 2, Name = "Nintendo"};
            GameConsoleManufacturer m3 = new GameConsoleManufacturer { Id = 3, Name = "Sega"};
            GameConsoleManufacturer m4 = new GameConsoleManufacturer { Id = 4, Name = "Sony"};
            
            gcList.Add(new GameConsole { Id = 1, Name = "XBox", Manufacturer =  m1 });
            gcList.Add(new GameConsole { Id = 2, Name = "XBox 360", Manufacturer =  m1 });
            gcList.Add(new GameConsole { Id = 3, Name = "Wii", Manufacturer =  m2 });
            gcList.Add(new GameConsole { Id = 4, Name = "Gameboy", Manufacturer =  m2 });
            gcList.Add(new GameConsole { Id = 5, Name = "Dreamcast", Manufacturer =  m3 });
            gcList.Add(new GameConsole { Id = 6, Name = "Playstation", Manufacturer =  m4 });
            gcList.Add(new GameConsole { Id = 7, Name = "Playstation 2", Manufacturer =  m4 });
            gcList.Add(new GameConsole { Id = 8, Name = "Playstation 3", Manufacturer =  m4 });
            gcList.Add(new GameConsole { Id = 9, Name = "PSP", Manufacturer =  m4 });

            return gcList;
        }

    }
}
